<template>
  <div class="tree_cont">
    <div>
      {{treeData.tit}}
      <span v-if="isOpen" @click="toggle">[{{open? '-':'+'}}]</span>
    </div>
    <ul v-if="isOpen" v-show="open">
      <item v-for='(data,index) in treeData.list' :treeData='data' :key='index'></item>
    </ul>
  </div>
</template>

<script>
  export default{
    name:'item',
    props:{
      treeData:{
        type:Object,
        required:true
      }
    },
    data(){
      return{
        open:false,
      }
    },
    methods:{
      toggle(){
        this.open = !this.open
      }
    },
    computed:{
      isOpen(){
        return this.treeData.list && this.treeData.list.length;
      }
    }
  }
</script>

<style scoped>
  ul{
    padding-left: .5rem;
  }
	
	.tree_cont{
		margin: .15rem .25rem;
		background: white;
		padding: .1rem .25rem;
	}
</style>
